#include "makefilewidget.h"
#include "ui_makefilewidget.h"

MakefileWidget::MakefileWidget(QWidget* parent)
    : QWidget(parent)
    , ui(new Ui::MakefileWidget)
{
    ui->setupUi(this);
}

MakefileWidget::~MakefileWidget() { delete ui; }

void MakefileWidget::setPath(QString path) { ui->checkBox->setText(path); }

QString MakefileWidget::path() { return ui->checkBox->text(); }

int MakefileWidget::Count()
{
    return ui->lcdNumber->intValue();
}

void MakefileWidget::setCount(int count, QString path)
{
    if (!path.contains(this->path())) {
        return;
    }
    if (count == 0) {
        ui->lcdNumber->display(0);
        files.clear();
    } else if (count == -1) {
        ui->lcdNumber->display(count--);
    } else if (count == 1) {
        if (!files.contains(path)) {
            ui->lcdNumber->display(count++);
            files.append(path);
        }
    }

    if (count > 0) {
        ui->lcdNumber->setStyleSheet("QLCDNumber { color: red; }");
    } else {
        ui->lcdNumber->setStyleSheet("QLCDNumber { color: black; }");
    }
}
